﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ComDevFx.Arch.Base.Persister.NH.Burrow;
using Microsoft.VisualStudio.TestTools.UnitTesting;


namespace ComDevFx.Arch.Base.Test
{
    //[TestClass]
    public class BootStrapTestCaseBaseGlobal
    {
        private static readonly BurrowFramework bf = new BurrowFramework();

        //[AssemblyInitialize]
        public static void Setup(TestContext context)
        {
            //FxArchBootstrapper.Init();
            //log4net.Config.XmlConfigurator.Configure();          //这句话不能少，否则看不到log4net的信息
            //var logger = LogManager.GetLogger(typeof(BootStrapTestCaseBase)); //这句话不能少，否则看不到log4net的信息
            bf.InitWorkSpace();
        }


        //[AssemblyCleanup]
        public static void Dispose()
        {
            bf.CloseWorkSpace();
        }

        /// <summary>
        /// to mimic ending a request and start a new one
        /// </summary>
        protected static void RestartBurrowEnvironment()
        {
            bf.CloseWorkSpace();
            bf.InitWorkSpace();
        }
    }

    [TestClass]
    public class BootStrapTestCaseBase
    {
        private static readonly BurrowFramework bf = new BurrowFramework();

        [TestInitialize]
        public void MyTestInitialize()
        {//log4net.config
            FxArchBootstrapper.Init();
            //log4net.Config.XmlConfigurator.Configure(); //这句话不能少，否则看不到log4net的信息
            //如果是将log4net的配置放在指在的文件，则加上下面这句
            //[assembly: log4net.Config.XmlConfigurator(ConfigFile = @"Log4\log4net.config", Watch = true)]  
            bf.InitWorkSpace();
        }

        [TestCleanup]
        public void MyTestCleanup()
        {
            bf.CloseWorkSpace();
        }

        public void ResetWorkSpace()
        {
            bf.CloseWorkSpace();
            bf.BurrowEnvironment.ShutDown(); //Restart the environment to prepare a fresh start 
            bf.BurrowEnvironment.Start();
            bf.InitWorkSpace();
        }
    }
}
